﻿using FlowCanvas.Nodes;
using Yoozoo.Gameplay.Liberty.AI;

namespace Yoozoo.Gameplay.Liberty.StreetEvent
{
    public class SetStreetEventNpcDisableOperate : CallableActionNode<int,bool,float,bool>
    {
        public override void Invoke(int streetNpcId, bool enable, float disableDuration = 0,bool force = false)
        {
            if (streetNpcId != LibertyAIUtils.PLAYER_AI_ID)
            {
                var m = StreetEventManager.GetInstance("").GetMonster(streetNpcId);
                if (m != null)
                {
                    var aiEntity = LibertyAIUtils.AIManager.NpcBirthManager.GetNpc(m.uniqueId);
                    if (aiEntity != null)
                    {
                        aiEntity.viewer.animationAgent.SetDisableOperate(enable, disableDuration, force);
                    }
                }
            }
            else
            {
                LibertyAIUtils.PlayerController.playerEntity.AIEntity.viewer.animationAgent.SetDisableOperate(enable, disableDuration, force);
            }
        }
    }
}